package pers.cz.postgirl.core.async;

import java.util.concurrent.*;

/**
 * @program: postgirl-client
 * @description: 异步处理的线程池
 * @author: Cheng Zhi
 * @create: 2023-05-30 15:35
 **/
public class DisruptorThreadPool {
    private static ThreadPoolExecutor executor;

    private static void init() {
        BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>();
        executor = new ThreadPoolExecutor(1, 3, 1, TimeUnit.MILLISECONDS, queue);
    }

    public static ThreadPoolExecutor getExecutor() {
        if (executor == null) {
            init();
        }
        return executor;
    }
}
